<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('泵站管理')" />
</head>
<body class="gray-bg">
    <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="pumpStation-form">
					<div class="select-list">
						<ul>
							<li>
								泵站名称：<input type="text" name="pumpName"/>
							</li>
							<li>
								地址：<input type="text" name="address"/>
							</li>
							<li>
								是否有效：<select name="isValid" th:with="type=${@dict.getType('biz_is_valid')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
		        <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="biz:pumpStation:add">
		            <i class="fa fa-plus"></i> 新增
		        </a>
		        <a class="btn btn-primary btn-edit disabled" onclick="$.operate.editTab()" shiro:hasPermission="biz:pumpStation:edit">
		            <i class="fa fa-edit"></i> 修改
		        </a>
		        <a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="biz:pumpStation:remove">
		            <i class="fa fa-remove"></i> 删除
		        </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
	            <table id="bootstrap-table" data-mobile-responsive="true"></table>
	        </div>
    	</div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('biz:pumpStation:edit')}]];
        var removeFlag = [[${@permission.hasPermi('biz:pumpStation:remove')}]];
        var detailFlag = [[${@permission.hasPermi('biz:pumpStation:detail')}]];
        var types = [[${@dict.getType('biz_is_valid')}]];
        var datas = [[${@dict.getType('biz_is_delete')}]];
        var prefix = ctx + "biz/pumpStation";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                detailUrl: prefix + "/detail/unit/{id}",
                modalName: "泵站",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '泵站ID' 
				},{
                    field : 'pumpCode',
                    title : '泵站编码'
				},{
					field : 'pumpName',
					title : '泵站名称' 
				},
				{
					field : 'address', 
					title : '泵站地址' 
				},
				{
					field : 'lng', 
					title : '泵站经度' 
				},
				{
					field : 'lat', 
					title : '泵站纬度' 
				},
				/* {
					field : 'userName', 
					title : '泵站管理者' 
				}, */
				{
					field : 'recentSupplyCapacity', 
					title : '近期供水' 
				},
				{
					field : 'forwardSupplyCapacity', 
					title : '远期供水' 
				},
				
				{
		            field: 'isValid',
		            title: '是否有效',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	return statusTools(row);
		            }
		        },
				/* {
		            field: 'isDeleted',
		            title: '是否删除',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(datas, value);
		            }
		        },
				{
					field : 'createBy', 
					title : '创建者' 
				},
				{
		            field: 'createTime',
		            title: '创建时间',
		            sortable: false
		        },*/
				{
                    field : 'hotVal',
                    title : '热力值'
				},
		        /* {
					field : 'updateBy', 
					title : '更新者' 
				},
				{
		            field: 'updateTime',
		            title: '更新时间',
		            sortable: true
		        }, */
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="#" onclick="$.operate.detailTab(\'' + row.id + '\')"><i class="fa fa-file-text"></i>查看详情</a> ');
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                      /*   actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>'); */
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        function statusTools(row) {
		    if (row.isValid == 0) {
    			return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
    		} else {
    			return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
    		}
		}
		
		function disable(id) {
			$.modal.confirm("确认要停用吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 });
		    })
		}

		function enable(id) {
			$.modal.confirm("确认要启用吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 });
		    })
		}
        
    </script>
</body>
</html>